21
22
24
25
29
30initially(punctuality(_, _)=punctual).
31
32initiatedAt(punctuality(Id, VehicleType)=punctual, T) :-
33 happensAt(stop_enter(Id, VehicleType, _StopCode, scheduled), T).
34
35initiatedAt(punctuality(Id, VehicleType)=punctual, T) :-
36 happensAt(stop_enter(Id, VehicleType, _StopCode, early), T).
37
38initiatedAt(punctuality(Id, VehicleType)=non_punctual, T) :-
39 happensAt(stop_enter(Id, VehicleType, _StopCode, late), T).
40
41initiatedAt(punctuality(Id, VehicleType)=non_punctual, T) :-
42 happensAt(stop_leave(Id, VehicleType, _StopCode, early), T).
43
66
68holdsFor(punctuality(Id, VehicleType)=non_punctual, NPI) :-
69 holdsFor(punctuality(Id, VehicleType)=punctual, PI),
70 complement_all([PI], NPI).
71
72
73happensAt(punctuality_change(Id, VehicleType, punctual), T) :-
74 happensAt(end(punctuality(Id, VehicleType)=non_punctual), T).
75
76happensAt(punctuality_change(Id, VehicleType, non_punctual), T) :-
77 happensAt(end(punctuality(Id, VehicleType)=punctual), T).
78
79
83
84holdsFor(driving_style(Id, VehicleType)=unsafe, UDI) :-
85 holdsFor(sharp_turn(Id, VehicleType)=very_sharp, VSTI),
86 holdsFor(abrupt_acceleration(Id, VehicleType)=very_abrupt, VAAI),
87 holdsFor(abrupt_deceleration(Id, VehicleType)=very_abrupt, VADI),
88 union_all([VSTI, VAAI, VADI], UDI).
89
90holdsFor(driving_style(Id, VehicleType)=uncomfortable, UDI) :-
91 holdsFor(sharp_turn(Id, VehicleType)=sharp, STI),
92 93 94 95 96 97 98 99 holdsFor(abrupt_acceleration(Id, VehicleType)=very_abrupt, VAAI),
100 holdsFor(abrupt_deceleration(Id, VehicleType)=very_abrupt, VADI),
101 relative_complement_all(STI, [VAAI, VADI], PureSharpTurn),
102 holdsFor(abrupt_acceleration(Id, VehicleType)=abrupt, AAI),
103 holdsFor(abrupt_deceleration(Id, VehicleType)=abrupt, ADI),
104 union_all([PureSharpTurn, AAI, ADI], UDI).
105
106
110
111holdsFor(driving_quality(Id, VehicleType)=high, HQDI) :-
112 holdsFor(punctuality(Id, VehicleType)=punctual, PunctualI),
113 holdsFor(driving_style(Id, VehicleType)=unsafe, USI),
114 holdsFor(driving_style(Id, VehicleType)=uncomfortable, UCI),
115 relative_complement_all(PunctualI, [USI, UCI], HQDI).
116
117holdsFor(driving_quality(Id, VehicleType)=medium, MQDI) :-
118 holdsFor(punctuality(Id, VehicleType)=punctual, PunctualI),
119 120 \+ PunctualI=[], !,
121 holdsFor(driving_style(Id, VehicleType)=uncomfortable, UCI),
122 intersect_all([PunctualI, UCI], MQDI).
123
125holdsFor(driving_quality(Id, VehicleType)=medium, []).
126
127holdsFor(driving_quality(Id, VehicleType)=low, LQDI) :-
128 holdsFor(punctuality(Id, VehicleType)=non_punctual, NPI),
129 holdsFor(driving_style(Id, VehicleType)=unsafe, USI),
130 union_all([NPI, USI], LQDI).
131
135
136holdsFor(passenger_comfort(Id, VehicleType)=reducing, RPCI) :-
137 holdsFor(driving_style(Id, VehicleType)=uncomfortable, UCI),
138 holdsFor(driving_style(Id, VehicleType)=unsafe, USI),
139 holdsFor(passenger_density(Id, VehicleType)=high, HPDI),
140 holdsFor(noise_level(Id, VehicleType)=high, HNLI),
141 holdsFor(internal_temperature(Id, VehicleType)=very_warm, VWITI),
142 holdsFor(internal_temperature(Id, VehicleType)=very_cold, VCITI),
143 union_all([UCI, USI, HPDI, HNLI, VWITI, VCITI], RPCI).
144
145
146initially(passenger_density(_, _)=low).
147initiates(passenger_density_change(Id, VehicleType, Value), passenger_density(Id, VehicleType)=Value, _T).
148
149initially(noise_level(_, _)=low).
150initiates(noise_level_change(Id, VehicleType, Value), noise_level(Id, VehicleType)=Value, _T).
151
152initially(internal_temperature(_, _)=normal).
153initiates(internal_temperature_change(Id, VehicleType, Value), internal_temperature(Id, VehicleType)=Value, _T).
154
158
159holdsFor(driver_comfort(Id, VehicleType)=reducing, RPCI) :-
160 holdsFor(driving_style(Id, VehicleType)=uncomfortable, UCI),
161 holdsFor(driving_style(Id, VehicleType)=unsafe, USI),
162 holdsFor(noise_level(Id, VehicleType)=high, HNLI),
163 holdsFor(internal_temperature(Id, VehicleType)=very_warm, VWITI),
164 holdsFor(internal_temperature(Id, VehicleType)=very_cold, VCITI),
165 union_all([UCI, USI, HNLI, VWITI, VCITI], RPCI).
166
170
171holdsFor(passenger_satisfaction(Id, VehicleType)=reducing, RPSI) :-
172 holdsFor(punctuality(Id, VehicleType)=non_punctual, NPI),
173 holdsFor(passenger_comfort(Id, VehicleType)=reducing, RPCI),
174 union_all([NPI, RPCI], RPSI)